<html lang="zh"><head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>气体灭火系统-消防系统计算平台</title>

    <link rel="stylesheet" type="text/css" href="/static/css/normalize.css">
    <link rel="stylesheet" type="text/css" href="/static/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="/static/css/demo.css">
    <link rel="stylesheet" href="/static/css/messenger.css" type="text/css">
    <link rel="stylesheet" href="/static/css/messenger-theme-block.css" type="text/css">
    <script src="/static/js/jquery-3.4.1.js"></script>
    <script type="text/javascript" src="/static/js/popper.min.js"></script>
    <script type="text/javascript" src="/static/js/bootstrap.js"></script>
    <script src="/static/js/messenger.js"></script>


    <link rel="stylesheet" href="/static/css/jsuites.css" type="text/css">
    <link rel="stylesheet" href="/static/css/jexcel.css" type="text/css">
    <script src="/static/js/jexcel.js"></script>
    <script src="/static/js/jsuites.js"></script>


</head>
<body>
<div class="jq22-container">

    <nav class="headertitle">
    <h1 class="navbar-header">消防系统计算平台 </h1>
    <div class="container-fluid">
        <div class="nav-item dropdown">
            <a data-toggle="dropdown" data-target="#" role="button">
                <div class="username">test<span class="caret"></span></div>
            </a>
            <div class="dropdown-menu" role="menu">
                <a class="dropdown-item" href="/logout/" role="menuitem">退出</a>
            </div>
        </div>
    </div>
</nav>
    <header class="jq22-header">
    <div class="jq22-demo center">
        <a href="/">项目列表</a>

        <a href="/introduction/5/">概况</a>

                <a href="/module/5/1/">消防系统用水量</a>

                <a href="/module/5/2/">消防水池及水箱容积</a>

                <a href="/module/5/3/">室外消火栓系统</a>

                <a href="/module/5/4/">室内消火栓系统</a>

                <a href="/module/5/5/">自动喷水灭火系统</a>

                <a href="/module/5/6/">消防转输系统</a>

                <a href="/module/5/7/">水喷雾灭火系统</a>

                <a href="/module/5/8/" class="current">气体灭火系统</a>

                <a href="/module/5/9/">灭火器配置</a>

                <a href="/module/5/10/">防护冷却系统</a>
    </div>
</header>
    <div class="content-table">
        <h2>1.气体灭火系统灭火剂选型</h2>
        <!--表9.1-->
        <div id="table29" class="jexcel_container"></div>
        <div>
            <input type="button" class="btn-primary" value="新增" onclick="addrow29()">
            <input type="button" class="btn-primary" value="保存" onclick="submit29()">
        </div>

        <h2>2.七氟丙烷气体灭火系统计算</h2>
        <h3>a.七氟丙烷气体灭火系统计算表</h3>
        <!--表9.2-1-->
        <div id="table30" class="jexcel_container"></div>
        <div>
            <input type="button" class="btn-primary" value="新增" onclick="addrow30()">
            <input type="button" class="btn-primary" value="保存" onclick="submit30()">
        </div>

        <h3>b.七氟丙烷气体灭火钢瓶选型表</h3>
        <!--表9.2-2-->
        <div id="table34" class="jexcel_container"></div>
        <div>
            <input type="button" class="btn-primary" value="新增" onclick="addrow34()">
            <input type="button" class="btn-primary" value="保存" onclick="submit34()">
        </div>

        <h2>3.IG541混合气体灭火系统计算</h2>
        <h3>a.IG541混合气体灭火系统计算表</h3>
        <!--表9.3-1-->
        <div id="table31" class="jexcel_container"></div>
        <div>
            <input type="button" class="btn-primary" value="新增" onclick="addrow31()">
            <input type="button" class="btn-primary" value="保存" onclick="submit31()">
        </div>

        <h3>b.IG541混合气体灭火钢瓶选型表</h3>
        <!--表9.3-2-->
        <div id="table32" class="jexcel_container"></div>
        <div>
            <input type="button" class="btn-primary" value="新增" onclick="addrow32()">
            <input type="button" class="btn-primary" value="保存" onclick="submit32()">
        </div>

        <h2>4.热气溶胶预制灭火系统计算</h2>
        <!--表9.4-->
        <div id="table33" class="jexcel_container"></div>
        <div>
            <input type="button" class="btn-primary" value="新增" onclick="addrow33()">
            <input type="button" class="btn-primary" value="保存" onclick="submit33()">
        </div>

        <h2>5.自定义系统</h2>
        <!--输入文本字段-->
        <div id="table43" class="jexcel_container"></div>
        <div>
            <input type="button" class="btn-primary" value="新增" onclick="addrow43()">
            <input type="button" class="btn-primary" value="保存" onclick="submit43()">
        </div>
        <input type="hidden" name="csrfmiddlewaretoken" value="frpAqnbThBquE0EAlNgWMcabiz52Q5sQjqNtfGG1XGGDyiVRcnIpuMTZVWOKUhRg">

    </div>


</div>



    <script>
$._messengerDefaults = ({
            extraClasses: 'messenger-fixed messenger-theme-block messenger-on-bottom messenger-on-left',
            theme:'block'
        })

        {#Array.prototype.countTimes = function(){#}
        {#    return this.reduce(function(times,name){#}
        {#        if(name in times){#}
        {#            times[name]++;#}
        {#        }else{#}
        {#            times[name] = 1;#}
        {#        }#}
        {#        return times;#}
        {#    },{});#}
        {#}#}

        //提交保存
        function submit29() {
            txt = JSON.stringify(table29.getDataAndFormula(false))
            csrf = $("input[name='csrfmiddlewaretoken']").val()
            $.post("/excel/616/", {
                data: txt,
                csrfmiddlewaretoken: csrf
            }, function (result) {
                $.globalMessenger().post({
                    message: result.data,
                    hideAfter: 6,
                    type: result.msg,
                    //showCloseButton: true
                });
            })
        }
        rows = {'196':1, '197': 1, '198': 1} // 系统名称对应的表中的行
        var olda=[];
        var beforeChange = function(instance, cell, x, y, value) {
            var row =parseInt(y)+1;
            if (!(row in olda)) {
                olda[row] = {'A': '', 'B': ''}
            }
            if (x == 0) {//改了“系统名称”
                if ('B' in olda[row] && olda[row]['B'] != '') {
                    if (olda[row]['A'] == '' && value != '') {
                        //chgmode = 'new'
                        olda[row]['A'] = value
                        newRows(row) // 新增
                    } else if (olda[row]['A'] != '' && value != '' && value != olda[row]['A']) {
                        //chgmode = 'change'
                        rows[olda[row]['A']]
                        olda[row]['A'] = value
                        deleteRows(row) //删除之前数据
                        newRows(row) //新增新数据
                    }
                } else {
                    olda[row]['A'] = value
                }
                checkUnique();
            }
            else if (x==1){//改了“防护区名称”
                if ('A' in olda[row] && olda[row]['A'] != '') {
                    if (olda[row]['B'] == '' && value != '') {
                        //chgmode = 'new'
                        olda[row]['B'] = value
                        newRows(row) // 新增
                    } else if (olda[row]['B'] != '' && value != '' && value != olda[row]['B']) {
                        //chgmode = 'change'
                        olda[row]['B'] = value
                        changeRows(row) // 修改
                    }
                } else {
                    olda[row]['B'] = value
                }
                checkUnique();
            }
        }
        function  checkUnique() {
            for(let i=1;i<olda.length-1;i++){
                    for(let j=i+1;j<olda.length;j++){
                        if(olda[i]['A']==olda[j]['A'] && olda[i]['B']==olda[j]['B'] && olda[i]['A']!='' && olda[i]['B']!='')
                            $.globalMessenger().post({
                                message: '“系统名称”、“防护区名称”组合的值应该唯一！',
                                hideAfter: 6,
                                type: 'error',
                            });
                    }
                }
        }
        // 删除行之前触发
        var beforeDelete = function (el, rowNumber, numOfRows) {
            var row = parseInt(rowNumber)+1;
            if (row in olda) {
                deleteRows(row)
                olda.splice(row, 1)
            }
            return true
        }

        table29 = jexcel(document.getElementById('table' + 29), {
                data: [['', '', '', '', '', '', '', '']],
                columns: [{'type': 'dropdown', 'title': '系统名称', 'width': 100, 'source': [{'id': 196, 'name': '七氟丙烷气体灭火系统', 'group': '', 'title': ''}, {'id': 197, 'name': 'IG541混合气体灭火系统', 'group': '', 'title': ''}, {'id': 198, 'name': '热气溶胶预制灭火系统', 'group': '', 'title': ''}]}, {'type': 'Text', 'title': '防护区名称', 'width': 100}, {'type': 'dropdown', 'title': '灭火设计浓度或惰化设计浓度(%)', 'width': 200, 'source': [{'id': 199, 'name': '5.8', 'group': '七氟丙烷', 'title': '固体表面火灾'}, {'id': 200, 'name': '10', 'group': '七氟丙烷', 'title': '图书、档案、票据和文物资料库等防护区'}, {'id': 201, 'name': '9', 'group': '七氟丙烷', 'title': '油浸变压器室、带油开关的配电室和自备发动机房等防护区'}, {'id': 202, 'name': '8', 'group': '七氟丙烷', 'title': '通讯机房和电子计算机房等防护区'}, {'id': 203, 'name': '28.1', 'group': 'IG541', 'title': '固体表面火灾'}, {'id': 204, 'name': '100', 'group': '热气溶胶', 'title': 'S型和K型热气溶胶灭固体表面火灾'}, {'id': 205, 'name': '130', 'group': '热气溶胶', 'title': 'S型热气溶胶灭通讯机房和电子计算机房等场所的电气设备火灾'}, {'id': 206, 'name': '140', 'group': '热气溶胶', 'title': 'S型和K型热气溶胶灭电缆隧道（夹层、井）及自备发电机房火灾'}]}, {'type': 'dropdown', 'title': '设计喷放时间(s)', 'width': 130, 'source': [{'id': 207, 'name': '8', 'group': '七氟丙烷', 'title': '在通讯机房和电子计算机房等防护区'}, {'id': 208, 'name': '10', 'group': '七氟丙烷', 'title': '其他防护区'}, {'id': 209, 'name': '90', 'group': '热气溶胶', 'title': '在通讯机房、电子计算机房等防护区'}, {'id': 210, 'name': '120', 'group': '热气溶胶', 'title': '其他防护区'}]}, {'type': 'dropdown', 'title': '灭火浸渍时间(min)', 'width': 140, 'source': [{'id': 211, 'name': '20', 'group': '七氟丙烷', 'title': '木材、纸张、织物等固体表面火灾'}, {'id': 212, 'name': '5', 'group': '七氟丙烷', 'title': '通讯机房、电子计算机房内的电气设备火灾'}, {'id': 213, 'name': '10', 'group': '七氟丙烷', 'title': '其他固体表面火灾'}, {'id': 214, 'name': '1', 'group': '七氟丙烷', 'title': '气体和液体火灾'}, {'id': 215, 'name': '20', 'group': 'IG541', 'title': '木材、纸张、织物等固体表面火灾'}, {'id': 216, 'name': '10', 'group': 'IG541', 'title': '通讯机房、电子计算机房内的电气设备火灾'}, {'id': 217, 'name': '10', 'group': 'IG541', 'title': '其他固体表面火灾'}, {'id': 218, 'name': '20', 'group': '热气溶胶', 'title': '木材、纸张、织物等固体表面火灾'}, {'id': 219, 'name': '10', 'group': '热气溶胶', 'title': '通讯机房、电子计算机房等防护区火灾及其他固体表面火灾'}]}, {'type': 'dropdown', 'title': '储存容器的增压压力等级(MPa)', 'width': 200, 'source': [{'id': 220, 'name': '2.5+0.1', 'group': '七氟丙烷', 'title': '一级'}, {'id': 221, 'name': '4.2+0.1', 'group': '七氟丙烷', 'title': '二级'}, {'id': 222, 'name': '5.6+0.1', 'group': '七氟丙烷', 'title': '三级'}, {'id': 223, 'name': '15.0', 'group': 'IG541', 'title': '一级'}, {'id': 225, 'name': '20', 'group': 'IG541', 'title': '二级'}]}, {'type': 'dropdown', 'title': '单位容积的充装量(kg/m³)', 'width': 200, 'source': [{'id': 224, 'name': '1120', 'group': '七氟丙烷', 'title': '一级增压储存容器'}, {'id': 226, 'name': '950', 'group': '七氟丙烷', 'title': '二级增压焊接结构储存容器'}, {'id': 227, 'name': '1120', 'group': '七氟丙烷', 'title': '二级增压无缝结构储存容器'}, {'id': 228, 'name': '1080', 'group': '七氟丙烷', 'title': '三级增压储存容器'}, {'id': 229, 'name': '211.15', 'group': 'IG541', 'title': '一级充压系统'}, {'id': 230, 'name': '281.06', 'group': 'IG541', 'title': '二级充压系统'}]}, {'type': 'Text', 'title': '备注', 'width': 100}],
                nestedHeaders: [[{'title': '', 'colspan': 1}, {'title': '', 'colspan': 1}, {'title': 'C1(C)', 'colspan': 1}, {'title': 't(C)', 'colspan': 1}, {'title': 't浸(C)', 'colspan': 1}, {'title': 'P0(C)', 'colspan': 1}, {'title': 'η(C)', 'colspan': 1}, {'title': '', 'colspan': 1}]],
                wordWrap: true,
                allowComments: true,
                //onchange: changed,
                onbeforechange: beforeChange,
                onbeforedeleterow: beforeDelete,
                allowManualInsertRow:false,
                contextMenu: function (obj, x, y, e) {
                    var items = [];
                    if (y != null) {
                        // Insert new row
                        if (obj.options.allowInsertRow == true) {
                            items.push({
                                title: obj.options.text.insertANewRowAfter,
                                onclick: function () {
                                    obj.insertRow(1, parseInt(y));
                                }
                            });
                        }

                        if (obj.options.allowDeleteRow == true) {
                            items.push({
                                title: obj.options.text.deleteSelectedRows,
                                onclick: function () {
                                    if(y==0){
                                        $.globalMessenger().post({
                                            message: '表格中至少应有1行',
                                            hideAfter: 6,
                                            type: 'info',
                                            });
                                    }else
                                    obj.deleteRow(obj.getSelectedRows().length ? undefined : parseInt(y));
                                }
                            });
                        }
                    }
                    return items;
                },
                text: {
                    insertANewRowAfter: "插入一行",
                    deleteSelectedRows: "删除选中行",
                }
            });


        //在合计行上方添加空行，只有一个合计行时减2
        function addrow29() {
            var com = [] //提示字段
            var fo = [] //公式字段
            var tal = []  //合计字段
            var len = table29.rows.length
            if (tal.length == 0) {//没有合计字段插入到最后
                table29.insertRow(1, len, true)
                len++
            } else {
                table29.insertRow(1, len - 1, true)
            }

            //添加提示信息
            for (i = 0; i < com.length; i++) {
                table29.setComments(com[i][0] + String(len), com[i][1])
            }

            //添加公式
            for (i = 0; i < fo.length; i++) {
                var id = fo[i][0] + String(len)
                var formula = '=' + fo[i][1].replace(/[A-Z]+/g, function (a) {
                                    if (a.length > 1) {
                                        return a
                                    } else {
                                        return a + len
                                    }
                                })
                table29.setValue(id, formula)
            }

            //更新合计公式
            if (tal.length > 0) {
                for (i = 1; i < tal.length; i++) {
                    formula = '=' + tal[0] + '('
                    id = tal[i] + String(len + 1)
                    formula += tal[i] + 1 + ':' + tal[i] + String(len) + ')'
                    table29.setValue(id, formula)
                }
            }
        }
        //初始化表格，添加注释，添加公式，添加合计
        function initRows29() {
            var com = [] //提示字段
            var fo = [] //公式字段
            var tal = []  //合计字段
            var len = table29.rows.length
            if (tal.length > 0) {//去掉最后一行
                len--;
            }
            if (len == 0) {
                table29.insertRow(1, len, true)
                len++
            }
            for (l = 1; l <= len; l++) {
                //添加注释
                for (i = 0; i < com.length; i++) {
                    table29.setComments(com[i][0] + String(len), com[i][1])
                }
                //添加公式
                for (i = 0; i < fo.length; i++) {
                    var id = fo[i][0] + String(l)
                    var formula = '=' + fo[i][1].replace(/[A-Z]+/g, function (a) {
                                    if (a.length > 1) {
                                        return a
                                    } else {
                                        return a + len
                                    }
                                })
                    table29.setValue(id, formula)
                }
            }
            //更新合计公式
            if (tal.length > 0) {
                for (i = 1; i < tal.length; i++) {
                    formula = '=' + tal[0] + '('
                    id = tal[i] + String(len + 1)
                    formula += tal[i] + 1 + ':' + tal[i] + String(len) + ')'
                    table29.setValue(id, formula)
                }
            }
        }
        initRows29();
        columnData = table29.getColumnData(0)
        arr = {'196': [30, 34], '197': [31, 32], '198': [33]} // 系统名称对应的表id

        for(i=0; i<columnData.length;i++){
            let row = i + 1;
            olda[row] = {}
            olda[row]['A'] = table29.getValue('A'+ row);
            olda[row]['B'] = table29.getValue('B'+ row);
            if (olda[row]['A'] != '') {
                olda[row]['ids'] = arr[olda[row]['A']] //对应的表
                olda[row]['row'] = rows[olda[row]['A']]++ //对应的表中的行
            }
        }

        var newRows = function (row) {
            ids = arr[olda[row]['A']]
            nrow = rows[olda[row]['A']]
            for (k = 0; k < ids.length; k++) {
                let id = ids[k]
                if (nrow != 1) {
                    addrow = 'addrow' + id + '()'
                    eval(addrow)
                }
                let setValue = 'table' + id + ".setValue('A"+ nrow +"','" + olda[row]['B'] + "')"
                eval(setValue)
            }
            olda[row]['ids'] = ids //对应的表
            olda[row]['row'] = rows[olda[row]['A']]++ //对应的表中的行
        }
        var changeRows = function (row) {
            ids = arr[olda[row]['A']]
            nrow = olda[row]['row']
            for (k = 0; k < ids.length; k++) {
                id = ids[k]
                setValue = 'table' + id + ".setValue('A"+ nrow +"','" + olda[row]['B'] + "')"
                eval(setValue)
            }
        }
        var deleteRows = function (row) { // 删除对应行
            ids = olda[row]['ids']
            nrow = olda[row]['row']
            for (k = 0; k < ids.length; k++) {
                id = ids[k]
                getLen = 'table' + id + '.rows.length'
                len = eval(getLen)
                if (len == 1) { //如果只有一行设置成空
                    setValue = 'table' + id + ".setValue('A"+ nrow +"','')"
                    eval(setValue)
                } else {
                    getValue = 'table' + id + ".getValue('A"+ nrow + "')"
                    value = eval(getValue)
                    if (value == olda[row]['B']) {
                        tmpRow = nrow - 1
                        setValue = 'table' + id + ".deleteRow("+ tmpRow + ")"
                        eval(setValue)
                    }
                }
            }
            for (k = 1; k < olda.length; k++) {//从1开始
                idss = olda[k]['ids']
                if (idss == ids && olda[k]['row'] > nrow) {
                    olda[k]['row']--
                }
            }
        }

        //提交保存
        function submit30() {
            txt = JSON.stringify(table30.getDataAndFormula(false))
            csrf = $("input[name='csrfmiddlewaretoken']").val()
            $.post("/excel/617/", {
                data: txt,
                csrfmiddlewaretoken: csrf
            }, function (result) {
                $.globalMessenger().post({
                    message: result.data,
                    hideAfter: 6,
                    type: result.msg,
                    //showCloseButton: true
                });
            })
        }

        table30 = jexcel(document.getElementById('table' + 30), {
            data: [['', '', '', '20', '', '', '', '', '', '', '1200', '']],
            columns: [{'type': 'Text', 'title': '防护区名称', 'width': 100}, {'type': 'Text', 'title': '防护区面积(m²)', 'width': 100}, {'type': 'Text', 'title': '防护区容积(m³)', 'width': 100}, {'type': 'Text', 'title': '防护区最低环境温度(℃)', 'width': 100}, {'type': 'text', 'title': '灭火剂的质量体积(m³/kg)', 'width': 100}, {'type': 'dropdown', 'title': '海拔高度修正系数', 'width': 100}, {'type': 'text', 'title': '灭火设计浓度或惰化设计浓度(%)', 'width': 150}, {'type': 'text', 'title': '灭火设计用量或惰化设计用量(kg)', 'width': 200}, {'type': 'text', 'title': '灭火剂设计喷放时间(s)', 'width': 150}, {'type': 'Text', 'title': '平均喷放速率(kg/s)', 'width': 100}, {'type': 'Text', 'title': '围护结构承受内压的允许压强(Pa)', 'width': 100}, {'type': 'Text', 'title': '泄压口面积(m²)', 'width': 100}],
            nestedHeaders: [[{'title': '', 'colspan': 1}, {'title': '', 'colspan': 1}, {'title': '', 'colspan': 1}, {'title': '', 'colspan': 1}, {'title': '0.1269+0.000513*T(B)', 'colspan': 1}, {'title': '', 'colspan': 1}, {'title': '', 'colspan': 1}, {'title': 'K*V(B)*C1(B)/(S(B)*(100-C1(B)))', 'colspan': 1}, {'title': '', 'colspan': 1}, {'title': 'W(B)/t(B)', 'colspan': 1}, {'title': '', 'colspan': 1}, {'title': '0.15*Qx(B)/Pf(B)^0.5', 'colspan': 1}], [{'title': '', 'colspan': 1}, {'title': 'F(B)', 'colspan': 1}, {'title': 'V(B)', 'colspan': 1}, {'title': 'T(B)', 'colspan': 1}, {'title': 'S(B)', 'colspan': 1}, {'title': 'K', 'colspan': 1}, {'title': 'C1(B)', 'colspan': 1}, {'title': 'W(B)', 'colspan': 1}, {'title': 't(B)', 'colspan': 1}, {'title': 'Qx(B)', 'colspan': 1}, {'title': 'Pf(B)', 'colspan': 1}, {'title': 'Fx(B)', 'colspan': 1}]],
            wordWrap: true,
            allowComments: true,
            contextMenu: function (obj, x, y, e) {
                var items = [];
                if (y != null) {
                    // Insert new row
                    if (obj.options.allowInsertRow == true) {
                        items.push({
                            title: obj.options.text.insertANewRowAfter,
                            onclick: function () {
                                obj.insertRow(1, parseInt(y));
                            }
                        });
                    }

                    if (obj.options.allowDeleteRow == true) {
                        items.push({
                            title: obj.options.text.deleteSelectedRows,
                            onclick: function () {
                                obj.deleteRow(obj.getSelectedRows().length ? undefined : parseInt(y));
                            }
                        });
                    }
                }
                return items;
            },
            text: {
                insertANewRowAfter: "插入一行",
                deleteSelectedRows: "删除选中行",
            }
        });


        //在合计行上方添加空行
        function addrow30() {
            var com = [] //提示字段
            var fo = [['E', '0.1269+0.000513*D'], ['H', 'F*C*G/(E*(100-G))'], ['J', 'H/I'], ['L', '0.15*J/K**0.5']] //公式字段
            var tal = []  //合计字段
            var len = table30.rows.length
            if (tal.length == 0) {//没有合计字段插入到最后
                table30.insertRow(1, len, true)
                len++
            } else {
                table30.insertRow(1, len - 1, true)
            }

            //添加提示信息
            for (i = 0; i < com.length; i++) {
                table30.setComments(com[i][0] + String(len), com[i][1])
            }

            //添加公式
            for (i = 0; i < fo.length; i++) {
                var id = fo[i][0] + String(len)
                var formula = '=' + fo[i][1].replace(/[A-Z]+/g, function (a) {
                                    if (a.length > 1) {
                                        return a
                                    } else {
                                        return a + len
                                    }
                                })
                table30.setValue(id, formula)
            }

            //更新合计公式
            if (tal.length > 0) {
                for (i = 1; i < tal.length; i++) {
                    formula = '=' + tal[0] + '('
                    id = tal[i] + String(len + 1)
                    formula += tal[i] + 1 + ':' + tal[i] + String(len) + ')'
                    table30.setValue(id, formula)
                }
            }
        }
        //初始化表格，添加注释，添加公式，添加合计
        function initRows30() {
            var com = [] //提示字段
            var fo = [['E', '0.1269+0.000513*D'], ['H', 'F*C*G/(E*(100-G))'], ['J', 'H/I'], ['L', '0.15*J/K**0.5']] //公式字段
            var tal = []  //合计字段
            var len = table30.rows.length
            if (tal.length > 0) {//去掉最后一行
                len--;
            }
            if (len == 0) {
                table30.insertRow(1, len, true)
                len++
            }
            for (l = 1; l <= len; l++) {
                //添加注释
                for (i = 0; i < com.length; i++) {
                    table30.setComments(com[i][0] + String(len), com[i][1])
                }
                //添加公式
                for (i = 0; i < fo.length; i++) {
                    var id = fo[i][0] + String(l)
                    var formula = '=' + fo[i][1].replace(/[A-Z]+/g, function (a) {
                                    if (a.length > 1) {
                                        return a
                                    } else {
                                        return a + len
                                    }
                                })
                }
            }
            //更新合计公式
            if (tal.length > 0) {
                for (i = 1; i < tal.length; i++) {
                    formula = '=' + tal[0] + '('
                    id = tal[i] + String(len + 1)
                    formula += tal[i] + 1 + ':' + tal[i] + String(len) + ')'
                    table30.setValue(id, formula)
                }
            }
        }
        initRows30();

        //提交保存
        function submit34() {
            txt = JSON.stringify(table34.getDataAndFormula(false))
            csrf = $("input[name='csrfmiddlewaretoken']").val()
            $.post("/excel/618/", {
                data: txt,
                csrfmiddlewaretoken: csrf
            }, function (result) {
                $.globalMessenger().post({
                    message: result.data,
                    hideAfter: 6,
                    type: result.msg,
                    //showCloseButton: true
                });
            })
        }

        table34 = jexcel(document.getElementById('table' + 34), {
            data: [['', '', '', '', '', '', '', '', '', '', '']],
            columns: [{'type': 'Text', 'title': '防护区名称', 'width': 100}, {'type': 'dropdown', 'title': '系统形式', 'width': 100, 'source': [{'id': 231, 'name': '预制式', 'group': '', 'title': ''}, {'id': 232, 'name': '管网式', 'group': '', 'title': ''}]}, {'type': 'text', 'title': '灭火设计用量或惰化设计用量(kg)', 'width': 150}, {'type': 'text', 'title': '灭火设计浓度或惰化设计浓度（%）', 'width': 150}, {'type': 'Text', 'title': '钢瓶压力等级(MPa)', 'width': 100}, {'type': 'dropdown', 'title': '钢瓶规格(L)', 'width': 100, 'source': [{'id': 233, 'name': '40', 'group': '', 'title': ''}, {'id': 234, 'name': '70', 'group': '', 'title': ''}, {'id': 235, 'name': '90', 'group': '', 'title': ''}, {'id': 236, 'name': '120', 'group': '', 'title': ''}, {'id': 237, 'name': '150', 'group': '', 'title': ''}, {'id': 238, 'name': '180', 'group': '', 'title': ''}]}, {'type': 'Text', 'title': '每个钢瓶充装量(kg/m³)', 'width': 100}, {'type': 'Text', 'title': '钢瓶数量(个)', 'width': 100}, {'type': 'Text', 'title': '钢瓶充装总剂量(kg)', 'width': 100}, {'type': 'text', 'title': '实际浓度(%)', 'width': 200}, {'type': 'Text', 'title': '备注', 'width': 100}],
            nestedHeaders: [[{'title': '', 'colspan': 1}, {'title': '', 'colspan': 1}, {'title': '', 'colspan': 1}, {'title': '', 'colspan': 1}, {'title': '', 'colspan': 1}, {'title': '', 'colspan': 1}, {'title': '', 'colspan': 1}, {'title': '', 'colspan': 1}, {'title': '0.001*η实(A)*n*Vb(A)', 'colspan': 1}, {'title': '100*W实(A)*S(B)/(K*V(B)+W实(A)*S(B))', 'colspan': 1}, {'title': '', 'colspan': 1}], [{'title': '', 'colspan': 1}, {'title': '', 'colspan': 1}, {'title': 'W(A)', 'colspan': 1}, {'title': 'C1(A)', 'colspan': 1}, {'title': 'P0(A)', 'colspan': 1}, {'title': 'Vb(A)', 'colspan': 1}, {'title': 'η实(A)', 'colspan': 1}, {'title': 'n', 'colspan': 1}, {'title': 'W实(A)', 'colspan': 1}, {'title': 'C实(A)', 'colspan': 1}, {'title': '', 'colspan': 1}]],
            wordWrap: true,
            allowComments: true,
            contextMenu: function (obj, x, y, e) {
                var items = [];
                if (y != null) {
                    // Insert new row
                    if (obj.options.allowInsertRow == true) {
                        items.push({
                            title: obj.options.text.insertANewRowAfter,
                            onclick: function () {
                                obj.insertRow(1, parseInt(y));
                            }
                        });
                    }

                    if (obj.options.allowDeleteRow == true) {
                        items.push({
                            title: obj.options.text.deleteSelectedRows,
                            onclick: function () {
                                obj.deleteRow(obj.getSelectedRows().length ? undefined : parseInt(y));
                            }
                        });
                    }
                }
                return items;
            },
            text: {
                insertANewRowAfter: "插入一行",
                deleteSelectedRows: "删除选中行",
            }
        });


        //在合计行上方添加空行，只有一个合计行时减2
        function addrow34() {
            var com = [['J', '不大于设计灭火浓度的1.1倍']] //提示字段
            var fo = [['I', '0.001*F*G*H']] //公式字段
            var tal = []  //合计字段
            var len = table34.rows.length
            if (tal.length == 0) {//没有合计字段插入到最后
                table34.insertRow(1, len, true)
                len++
            } else {
                table34.insertRow(1, len - 1, true)
            }

            //添加提示信息
            for (i = 0; i < com.length; i++) {
                table34.setComments(com[i][0] + String(len), com[i][1])
            }

            //添加公式
            for (i = 0; i < fo.length; i++) {
                var id = fo[i][0] + String(len)
                var formula = '=' + fo[i][1].replace(/[A-Z]+/g, function (a) {
                                    if (a.length > 1) {
                                        return a
                                    } else {
                                        return a + len
                                    }
                                })
                table34.setValue(id, formula)
            }

            //更新合计公式
            if (tal.length > 0) {
                for (i = 1; i < tal.length; i++) {
                    formula = '=' + tal[0] + '('
                    id = tal[i] + String(len + 1)
                    formula += tal[i] + 1 + ':' + tal[i] + String(len) + ')'
                    table34.setValue(id, formula)
                }
            }
        }
        //初始化表格，添加注释，添加公式，添加合计
        function initRows34() {
            var com = [['J', '不大于设计灭火浓度的1.1倍']] //提示字段
            var fo = [['I', '0.001*F*G*H']] //公式字段
            var tal = []  //合计字段
            var len = table34.rows.length
            if (tal.length > 0) {//去掉最后一行
                len--;
            }
            if (len == 0) {
                table34.insertRow(1, len, true)
                len++
            }
            for (l = 1; l <= len; l++) {
                //添加注释
                for (i = 0; i < com.length; i++) {
                    table34.setComments(com[i][0] + String(len), com[i][1])
                }
                //添加公式
                for (i = 0; i < fo.length; i++) {
                    var id = fo[i][0] + String(l)
                    var formula = '=' + fo[i][1].replace(/[A-Z]+/g, function (a) {
                                    if (a.length > 1) {
                                        return a
                                    } else {
                                        return a + len
                                    }
                                })
                    table34.setValue(id, formula)
                }
            }
            //更新合计公式
            if (tal.length > 0) {
                for (i = 1; i < tal.length; i++) {
                    formula = '=' + tal[0] + '('
                    id = tal[i] + String(len + 1)
                    formula += tal[i] + 1 + ':' + tal[i] + String(len) + ')'
                    table34.setValue(id, formula)
                }
            }
        }
        initRows34();

        //提交保存
        function submit31() {
            txt = JSON.stringify(table31.getDataAndFormula(false))
            csrf = $("input[name='csrfmiddlewaretoken']").val()
            $.post("/excel/619/", {
                data: txt,
                csrfmiddlewaretoken: csrf
            }, function (result) {
                $.globalMessenger().post({
                    message: result.data,
                    hideAfter: 6,
                    type: result.msg,
                    //showCloseButton: true
                });
            })
        }

        table31 = jexcel(document.getElementById('table' + 31), {
            data: [['', '', '', '20', '', '', '', '', '', '', '1200', '']],
            columns: [{'type': 'Text', 'title': '防护区名称', 'width': 100}, {'type': 'Text', 'title': '防护区面积(m²)', 'width': 100}, {'type': 'Text', 'title': '防护区容积(m³)', 'width': 100}, {'type': 'Text', 'title': '防护区最低环境温度(℃)', 'width': 100}, {'type': 'Text', 'title': '灭火剂的质量体积(m³/kg)', 'width': 100}, {'type': 'dropdown', 'title': '海拔高度修正系数', 'width': 100, 'source': [{'id': 239, 'name': '1.130', 'group': '', 'title': '海拔高度-1000m'}, {'id': 240, 'name': '1.000', 'group': '', 'title': '海拔高度0m'}, {'id': 241, 'name': '0.885', 'group': '', 'title': '海拔高度1000m'}, {'id': 242, 'name': '0.830', 'group': '', 'title': '海拔高度1500m'}, {'id': 243, 'name': '0.785', 'group': '', 'title': '海拔高度2000m'}, {'id': 244, 'name': '0.735', 'group': '', 'title': '海拔高度2500m'}, {'id': 245, 'name': '0.690', 'group': '', 'title': '海拔高度3000m'}, {'id': 246, 'name': '0.650', 'group': '', 'title': '海拔高度3500m'}, {'id': 247, 'name': '0.610', 'group': '', 'title': '海拔高度4000m'}, {'id': 248, 'name': '0.565', 'group': '', 'title': '海拔高度4500m'}]}, {'type': 'Text', 'title': '灭火设计浓度或惰化设计浓度(%)', 'width': 100}, {'type': 'text', 'title': '灭火设计用量或惰化设计用量(kg)', 'width': 200}, {'type': 'text', 'title': '喷放至设计用量的95%时的喷放时间(s)', 'width': 200}, {'type': 'Text', 'title': '平均喷放速率(kg/s)', 'width': 100}, {'type': 'Text', 'title': '围护结构承受内压的允许压强(Pa)', 'width': 100}, {'type': 'Text', 'title': '泄压口面积(m²)', 'width': 100}],
            nestedHeaders: [[{'title': '', 'colspan': 1}, {'title': '', 'colspan': 1}, {'title': '', 'colspan': 1}, {'title': '', 'colspan': 1}, {'title': '0.6575+0.0024*T(B)', 'colspan': 1}, {'title': '', 'colspan': 1}, {'title': '', 'colspan': 1}, {'title': 'K*V(B)*ln(100/100-C1(B))/S(B)', 'colspan': 1}, {'title': '', 'colspan': 1}, {'title': '0.95*W(B)/t(B)', 'colspan': 1}, {'title': '', 'colspan': 1}, {'title': '1.1*Qx(B)/Pf(B)^0.5', 'colspan': 1}], [{'title': '', 'colspan': 1}, {'title': 'F(B)', 'colspan': 1}, {'title': 'V(B)', 'colspan': 1}, {'title': 'T(B)', 'colspan': 1}, {'title': 'S(B)', 'colspan': 1}, {'title': 'K', 'colspan': 1}, {'title': 'C1(B)', 'colspan': 1}, {'title': 'W(B)', 'colspan': 1}, {'title': 't(B)', 'colspan': 1}, {'title': 'Qx(B)', 'colspan': 1}, {'title': 'Pf(B)', 'colspan': 1}, {'title': 'Fx(B)', 'colspan': 1}]],
            wordWrap: true,
            allowComments: true,
            contextMenu: function (obj, x, y, e) {
                var items = [];
                if (y != null) {
                    // Insert new row
                    if (obj.options.allowInsertRow == true) {
                        items.push({
                            title: obj.options.text.insertANewRowAfter,
                            onclick: function () {
                                obj.insertRow(1, parseInt(y));
                            }
                        });
                    }

                    if (obj.options.allowDeleteRow == true) {
                        items.push({
                            title: obj.options.text.deleteSelectedRows,
                            onclick: function () {
                                obj.deleteRow(obj.getSelectedRows().length ? undefined : parseInt(y));
                            }
                        });
                    }
                }
                return items;
            },
            text: {
                insertANewRowAfter: "插入一行",
                deleteSelectedRows: "删除选中行",
            }
        });


        //在合计行上方添加空行，只有一个合计行时减2
        function addrow31() {
            var com = [] //提示字段
            var fo = [['E', '0.6575+0.0024*D'], ['H', 'F*C*LN(100/100-G)/E'], ['J', '0.95*H/I'], ['L', '1.1*J/K**0.5']] //公式字段
            var tal = []  //合计字段
            var len = table31.rows.length
            if (tal.length == 0) {//没有合计字段插入到最后
                table31.insertRow(1, len, true)
                len++
            } else {
                table31.insertRow(1, len - 1, true)
            }

            //添加提示信息
            for (i = 0; i < com.length; i++) {
                table31.setComments(com[i][0] + String(len), com[i][1])
            }

            //添加公式
            for (i = 0; i < fo.length; i++) {
                var id = fo[i][0] + String(len)
                var formula = '=' + fo[i][1].replace(/[A-Z]+/g, function (a) {
                                    if (a.length > 1) {
                                        return a
                                    } else {
                                        return a + len
                                    }
                                })
                table31.setValue(id, formula)
            }

            //更新合计公式
            if (tal.length > 0) {
                for (i = 1; i < tal.length; i++) {
                    formula = '=' + tal[0] + '('
                    id = tal[i] + String(len + 1)
                    formula += tal[i] + 1 + ':' + tal[i] + String(len) + ')'
                    table31.setValue(id, formula)
                }
            }
        }
        //初始化表格，添加注释，添加公式，添加合计
        function initRows31() {
            var com = [] //提示字段
            var fo = [['E', '0.6575+0.0024*D'], ['H', 'F*C*LN(100/100-G)/E'], ['J', '0.95*H/I'], ['L', '1.1*J/K**0.5']] //公式字段
            var tal = []  //合计字段
            var len = table31.rows.length
            if (tal.length > 0) {//去掉最后一行
                len--;
            }
            if (len == 0) {
                table31.insertRow(1, len, true)
                len++
            }
            for (l = 1; l <= len; l++) {
                //添加注释
                for (i = 0; i < com.length; i++) {
                    table31.setComments(com[i][0] + String(len), com[i][1])
                }
                //添加公式
                for (i = 0; i < fo.length; i++) {
                    var id = fo[i][0] + String(l)
                    var formula = '=' + fo[i][1].replace(/[A-Z]+/g, function (a) {
                                    if (a.length > 1) {
                                        return a
                                    } else {
                                        return a + len
                                    }
                                })
                    table31.setValue(id, formula)
                }
            }
            //更新合计公式
            if (tal.length > 0) {
                for (i = 1; i < tal.length; i++) {
                    formula = '=' + tal[0] + '('
                    id = tal[i] + String(len + 1)
                    formula += tal[i] + 1 + ':' + tal[i] + String(len) + ')'
                    table31.setValue(id, formula)
                }
            }
        }
        initRows31();

        //提交保存
        function submit32() {
            txt = JSON.stringify(table32.getDataAndFormula(false))
            csrf = $("input[name='csrfmiddlewaretoken']").val()
            $.post("/excel/620/", {
                data: txt,
                csrfmiddlewaretoken: csrf
            }, function (result) {
                $.globalMessenger().post({
                    message: result.data,
                    hideAfter: 6,
                    type: result.msg,
                    //showCloseButton: true
                });
            })
        }

        table32 = jexcel(document.getElementById('table' + 32), {
            data: [['', '', '', '', '', '', '', '', '']],
            columns: [{'type': 'Text', 'title': '防护区名称', 'width': 100}, {'type': 'text', 'title': '灭火设计用量或惰化设计用量(kg)', 'width': 200}, {'type': 'text', 'title': '灭火设计浓度或惰化设计浓度(%)', 'width': 200}, {'type': 'Text', 'title': '钢瓶压力等级(Mpa)', 'width': 100}, {'type': 'dropdown', 'title': '钢瓶规格(L)', 'width': 100, 'source': [{'id': 249, 'name': '70', 'group': '', 'title': ''}, {'id': 250, 'name': '80', 'group': '', 'title': ''}, {'id': 251, 'name': '90', 'group': '', 'title': ''}, {'id': 252, 'name': '120', 'group': '', 'title': ''}]}, {'type': 'Text', 'title': '每个钢瓶充装量(kg/m³)', 'width': 100}, {'type': 'Text', 'title': '钢瓶数量(个)', 'width': 100}, {'type': 'text', 'title': '钢瓶充装总剂量(kg)', 'width': 150}, {'type': 'Text', 'title': '备注', 'width': 100}],
            nestedHeaders: [[{'title': '', 'colspan': 1}, {'title': '', 'colspan': 1}, {'title': '', 'colspan': 1}, {'title': '', 'colspan': 1}, {'title': '', 'colspan': 1}, {'title': '', 'colspan': 1}, {'title': '', 'colspan': 1}, {'title': '0.001*η实(A)*n*Vb(A)', 'colspan': 1}, {'title': '', 'colspan': 1}], [{'title': '', 'colspan': 1}, {'title': 'W(A)', 'colspan': 1}, {'title': 'C1(A)', 'colspan': 1}, {'title': 'P0(A)', 'colspan': 1}, {'title': 'Vb(A)', 'colspan': 1}, {'title': 'η实(A)', 'colspan': 1}, {'title': 'n', 'colspan': 1}, {'title': 'W实(A)', 'colspan': 1}, {'title': '', 'colspan': 1}]],
            wordWrap: true,
            allowComments: true,
            contextMenu: function (obj, x, y, e) {
                var items = [];
                if (y != null) {
                    // Insert new row
                    if (obj.options.allowInsertRow == true) {
                        items.push({
                            title: obj.options.text.insertANewRowAfter,
                            onclick: function () {
                                obj.insertRow(1, parseInt(y));
                            }
                        });
                    }

                    if (obj.options.allowDeleteRow == true) {
                        items.push({
                            title: obj.options.text.deleteSelectedRows,
                            onclick: function () {
                                obj.deleteRow(obj.getSelectedRows().length ? undefined : parseInt(y));
                            }
                        });
                    }
                }
                return items;
            },
            text: {
                insertANewRowAfter: "插入一行",
                deleteSelectedRows: "删除选中行",
            }
        });


        //在合计行上方添加空行，只有一个合计行时减2
        function addrow32() {
            var com = [] //提示字段
            var fo = [['H', '0.001*Q*R*P']] //公式字段
            var tal = []  //合计字段
            var len = table32.rows.length
            if (tal.length == 0) {//没有合计字段插入到最后
                table32.insertRow(1, len, true)
                len++
            } else {
                table32.insertRow(1, len - 1, true)
            }

            //添加提示信息
            for (i = 0; i < com.length; i++) {
                table32.setComments(com[i][0] + String(len), com[i][1])
            }

            //添加公式
            for (i = 0; i < fo.length; i++) {
                var id = fo[i][0] + String(len)
                var formula = '=' + fo[i][1].replace(/[A-Z]+/g, function (a) {
                                    if (a.length > 1) {
                                        return a
                                    } else {
                                        return a + len
                                    }
                                })
                table32.setValue(id, formula)
            }

            //更新合计公式
            if (tal.length > 0) {
                for (i = 1; i < tal.length; i++) {
                    formula = '=' + tal[0] + '('
                    id = tal[i] + String(len + 1)
                    formula += tal[i] + 1 + ':' + tal[i] + String(len) + ')'
                    table32.setValue(id, formula)
                }
            }
        }
        //初始化表格，添加注释，添加公式，添加合计
        function initRows32() {
            var com = [] //提示字段
            var fo = [['H', '0.001*Q*R*P']] //公式字段
            var tal = []  //合计字段
            var len = table32.rows.length
            if (tal.length > 0) {//去掉最后一行
                len--;
            }
            if (len == 0) {
                table32.insertRow(1, len, true)
                len++
            }
            for (l = 1; l <= len; l++) {
                //添加注释
                for (i = 0; i < com.length; i++) {
                    table32.setComments(com[i][0] + String(len), com[i][1])
                }
                //添加公式
                for (i = 0; i < fo.length; i++) {
                    var id = fo[i][0] + String(l)
                    var formula = '=' + fo[i][1].replace(/[A-Z]+/g, function (a) {
                                    if (a.length > 1) {
                                        return a
                                    } else {
                                        return a + len
                                    }
                                })
                    table32.setValue(id, formula)
                }
            }
            //更新合计公式
            if (tal.length > 0) {
                for (i = 1; i < tal.length; i++) {
                    formula = '=' + tal[0] + '('
                    id = tal[i] + String(len + 1)
                    formula += tal[i] + 1 + ':' + tal[i] + String(len) + ')'
                    table32.setValue(id, formula)
                }
            }
        }
        initRows32();

        //提交保存
        function submit33() {
            txt = JSON.stringify(table33.getDataAndFormula(false))
            csrf = $("input[name='csrfmiddlewaretoken']").val()
            $.post("/excel/621/", {
                data: txt,
                csrfmiddlewaretoken: csrf
            }, function (result) {
                $.globalMessenger().post({
                    message: result.data,
                    hideAfter: 6,
                    type: result.msg,
                    //showCloseButton: true
                });
            })
        }

        table33 = jexcel(document.getElementById('table' + 33), {
            data: [['', '', '', '', '', '', '']],
            columns: [{'type': 'Text', 'title': '防护区名称', 'width': 100}, {'type': 'text', 'title': '防护区面积(m²)', 'width': 150}, {'type': 'text', 'title': '防护区容积(m³)', 'width': 150}, {'type': 'text', 'title': '灭火设计密度(g/m³)', 'width': 160}, {'type': 'dropdown', 'title': '体积修正系数', 'width': 140, 'source': [{'id': 253, 'name': '1.0', 'group': '', 'title': 'V<500m³'}, {'id': 254, 'name': '1.1', 'group': '', 'title': '500m³<=V<1000m³'}, {'id': 255, 'name': '1.2', 'group': '', 'title': 'V>=1000m³'}]}, {'type': 'text', 'title': '灭火剂设计用量(kg)', 'width': 150}, {'type': 'Text', 'title': '备注', 'width': 100}],
            nestedHeaders: [[{'title': '', 'colspan': 1}, {'title': '', 'colspan': 1}, {'title': '', 'colspan': 1}, {'title': '', 'colspan': 1}, {'title': '', 'colspan': 1}, {'title': '0.001*V(B)*C2(B)*Kv(B)', 'colspan': 1}, {'title': '', 'colspan': 1}], [{'title': '', 'colspan': 1}, {'title': 'F(B)', 'colspan': 1}, {'title': 'V(B)', 'colspan': 1}, {'title': 'C2(B)', 'colspan': 1}, {'title': 'Kv(B)', 'colspan': 1}, {'title': 'W(B)', 'colspan': 1}, {'title': '', 'colspan': 1}]],
            wordWrap: true,
            allowComments: true,
            contextMenu: function (obj, x, y, e) {
                var items = [];
                if (y != null) {
                    // Insert new row
                    if (obj.options.allowInsertRow == true) {
                        items.push({
                            title: obj.options.text.insertANewRowAfter,
                            onclick: function () {
                                obj.insertRow(1, parseInt(y));
                            }
                        });
                    }

                    if (obj.options.allowDeleteRow == true) {
                        items.push({
                            title: obj.options.text.deleteSelectedRows,
                            onclick: function () {
                                obj.deleteRow(obj.getSelectedRows().length ? undefined : parseInt(y));
                            }
                        });
                    }
                }
                return items;
            },
            text: {
                insertANewRowAfter: "插入一行",
                deleteSelectedRows: "删除选中行",
            }
        });


        //在合计行上方添加空行，只有一个合计行时减2
        function addrow33() {
            var com = [] //提示字段
            var fo = [['F', '0.001*C*D*E']] //公式字段
            var tal = []  //合计字段
            var len = table33.rows.length
            if (tal.length == 0) {//没有合计字段插入到最后
                table33.insertRow(1, len, true)
                len++
            } else {
                table33.insertRow(1, len - 1, true)
            }

            //添加提示信息
            for (i = 0; i < com.length; i++) {
                table33.setComments(com[i][0] + String(len), com[i][1])
            }

            //添加公式
            for (i = 0; i < fo.length; i++) {
                var id = fo[i][0] + String(len)
                var formula = '=' + fo[i][1].replace(/[A-Z]+/g, function (a) {
                                    if (a.length > 1) {
                                        return a
                                    } else {
                                        return a + len
                                    }
                                })
                table33.setValue(id, formula)
            }

            //更新合计公式
            if (tal.length > 0) {
                for (i = 1; i < tal.length; i++) {
                    formula = '=' + tal[0] + '('
                    id = tal[i] + String(len + 1)
                    formula += tal[i] + 1 + ':' + tal[i] + String(len) + ')'
                    table33.setValue(id, formula)
                }
            }
        }
        //初始化表格，添加注释，添加公式，添加合计
        function initRows33() {
            var com = [] //提示字段
            var fo = [['F', '0.001*C*D*E']] //公式字段
            var tal = []  //合计字段
            var len = table33.rows.length
            if (tal.length > 0) {//去掉最后一行
                len--;
            }
            if (len == 0) {
                table33.insertRow(1, len, true)
                len++
            }
            for (l = 1; l <= len; l++) {
                //添加注释
                for (i = 0; i < com.length; i++) {
                    table33.setComments(com[i][0] + String(len), com[i][1])
                }
                //添加公式
                for (i = 0; i < fo.length; i++) {
                    var id = fo[i][0] + String(l)
                    var formula = '=' + fo[i][1].replace(/[A-Z]+/g, function (a) {
                                    if (a.length > 1) {
                                        return a
                                    } else {
                                        return a + len
                                    }
                                })
                    table33.setValue(id, formula)
                }
            }
            //更新合计公式
            if (tal.length > 0) {
                for (i = 1; i < tal.length; i++) {
                    formula = '=' + tal[0] + '('
                    id = tal[i] + String(len + 1)
                    formula += tal[i] + 1 + ':' + tal[i] + String(len) + ')'
                    table33.setValue(id, formula)
                }
            }
        }
        initRows33();

        //提交保存
        function submit43() {
            txt = JSON.stringify(table43.getDataAndFormula(false))
            csrf = $("input[name='csrfmiddlewaretoken']").val()
            $.post("/excel/622/", {
                data: txt,
                csrfmiddlewaretoken: csrf
            }, function (result) {
                $.globalMessenger().post({
                    message: result.data,
                    hideAfter: 6,
                    type: result.msg,
                    //showCloseButton: true
                });
            })
        }

        table43 = jexcel(document.getElementById('table' + 43), {
            data: [['']],
            columns: [{'type': 'text', 'title': '说明', 'width': 1000}],
            nestedHeaders: [],
            wordWrap: true,
            allowComments: true,
            contextMenu: function (obj, x, y, e) {
                var items = [];
                if (y != null) {
                    // Insert new row
                    if (obj.options.allowInsertRow == true) {
                        items.push({
                            title: obj.options.text.insertANewRowAfter,
                            onclick: function () {
                                obj.insertRow(1, parseInt(y));
                            }
                        });
                    }

                    if (obj.options.allowDeleteRow == true) {
                        items.push({
                            title: obj.options.text.deleteSelectedRows,
                            onclick: function () {
                                obj.deleteRow(obj.getSelectedRows().length ? undefined : parseInt(y));
                            }
                        });
                    }
                }
                return items;
            },
            text: {
                insertANewRowAfter: "插入一行",
                deleteSelectedRows: "删除选中行",
            }
        });


        //在合计行上方添加空行，只有一个合计行时减2
        function addrow43() {
            var com = [] //提示字段
            var fo = [] //公式字段
            var tal = []  //合计字段
            var len = table43.rows.length
            if (tal.length == 0) {//没有合计字段插入到最后
                table43.insertRow(1, len, true)
                len++
            } else {
                table43.insertRow(1, len - 1, true)
            }

            //添加提示信息
            for (i = 0; i < com.length; i++) {
                table43.setComments(com[i][0] + String(len), com[i][1])
            }

            //添加公式
            for (i = 0; i < fo.length; i++) {
                var id = fo[i][0] + String(len)
                var formula = '=' + fo[i][1].replace(/[A-Z]+/g, function (a) {
                                    if (a.length > 1) {
                                        return a
                                    } else {
                                        return a + len
                                    }
                                })
                table43.setValue(id, formula)
            }

            //更新合计公式
            if (tal.length > 0) {
                for (i = 1; i < tal.length; i++) {
                    formula = '=' + tal[0] + '('
                    id = tal[i] + String(len + 1)
                    formula += tal[i] + 1 + ':' + tal[i] + String(len) + ')'
                    table43.setValue(id, formula)
                }
            }
        }
        //初始化表格，添加注释，添加公式，添加合计
        function initRows43() {
            var com = [] //提示字段
            var fo = [] //公式字段
            var tal = []  //合计字段
            var len = table43.rows.length
            if (tal.length > 0) {//去掉最后一行
                len--;
            }
            if (len == 0) {
                table43.insertRow(1, len, true)
                len++
            }
            for (l = 1; l <= len; l++) {
                //添加注释
                for (i = 0; i < com.length; i++) {
                    table43.setComments(com[i][0] + String(len), com[i][1])
                }
                //添加公式
                for (i = 0; i < fo.length; i++) {
                    var id = fo[i][0] + String(l)
                    var formula = '=' + fo[i][1].replace(/[A-Z]+/g, function (a) {
                                    if (a.length > 1) {
                                        return a
                                    } else {
                                        return a + len
                                    }
                                })
                    table43.setValue(id, formula)
                }
            }
            //更新合计公式
            if (tal.length > 0) {
                for (i = 1; i < tal.length; i++) {
                    formula = '=' + tal[0] + '('
                    id = tal[i] + String(len + 1)
                    formula += tal[i] + 1 + ':' + tal[i] + String(len) + ')'
                    table43.setValue(id, formula)
                }
            }
        }
        initRows43();


    </script>



</body></html>